package data.vip;

import java.util.ArrayList;

import data.ListInterIterator;
import data.goods.GoodsType;

public class Vipfind {
	private ArrayList<Vip> list;
	private ArrayList<Vip> find=new ArrayList<Vip>();
	
	public Vipfind (ListInterIterator<Vip> list){
		this.list=list.toArray();
	}

	public ListInterIterator<Vip> find(String key,String message){
		if(key.equals("name")){
			findbyname(message);
		}
		else if(key.equals("sex")){
			findbysex(message);
		}
		else if(key.equals("birth")){
			findbybirth(message);
		}
		else if(key.equals("score")){
			findbyscore(message);
		}
		else if(key.equals("morescore")){
			findbymorescore(message);
		}
		return new ListInterIterator<Vip>(find);
	}
	
	private void findbyname(String message){
		for(int i=0;i<list.size();i++){
			if(list.get(i).getName().equals(message)){
				find.add(list.get(i));
			}
		}
	}
	
	private void findbysex(String message){
		for(int i=0;i<list.size();i++){
			if(String.valueOf(list.get(i).getSex()).equals(message)){
				find.add(list.get(i));
			}
		}
	}
	
	
	private void findbybirth(String message){
		for(int i=0;i<list.size();i++){
			if(list.get(i).getBirth().equals(message)){
				find.add(list.get(i));
			}
		}
	}
	
	private void findbyscore(String message){
		for(int i=0;i<list.size();i++){
			if(String.valueOf(list.get(i).getScore()).equals(message)){
				find.add(list.get(i));
			}
		}
	}
	
	private void findbymorescore(String message){
		for(int i=0;i<list.size();i++){
			if(String.valueOf(list.get(i).getScore()).compareTo(message)>0){
				find.add(list.get(i));
			}
		}
	}
}
